package net.tycmc.cty.ctyms.web.Action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import net.sf.json.JSONObject;
import net.tycmc.bulb.common.util.DateUtil;
import net.tycmc.cty.ctyms.timejob.iems.service.DataMissingMonitorService;
import net.tycmc.cty.ctyms.web.Service.DataMonitorListService;

public class DataMonitorListAction extends BaseActionS2 {

	private DataMonitorListService datamls;
	private DataMissingMonitorService dataMissingMonitorService;
	public DataMonitorListService getDatamls() {
		return datamls;
	}
	public void setDatamls(DataMonitorListService datamls) {
		this.datamls = datamls;
	}

	public DataMissingMonitorService getDataMissingMonitorService() {
		return dataMissingMonitorService;
	}
	public void setDataMissingMonitorService(
			DataMissingMonitorService dataMissingMonitorService) {
		this.dataMissingMonitorService = dataMissingMonitorService;
	}
	/**
	 * 列表页
	 * @return
	 */
	public String getDataOfHistory(){
		String endTime=DateUtil.addDay(-7);
		String beginTime=DateUtil.addDay(-9);
		Map<String,Object>map=datamls.getdataofHistory(beginTime,endTime);
		request.setAttribute("map",map);
		return "DataMointorList";
	}
	public String reloadMonitorList() throws IOException{
		String endTime=DateUtil.addDay(-7);
		String beginTime=DateUtil.addDay(-7);
		//手动统计之前，先修改标记表,并清空昨日数据
		int num=datamls.updateFlagTable();
		PrintWriter out=response.getWriter();
		dataMissingMonitorService.getVclNoParam();//执行统计
			Map<String,Object>map=datamls.getdataofHistory(beginTime,endTime);
			JSONObject json=JSONObject.fromObject(map);
			out.print("{'data':"+json.toString()+"}");
		return null;
	}
}

